using Headspring.Training.Domain.Model;
using Headspring.Training.Domain.Services;
using Headspring.Training.WebUI.Views;

namespace Headspring.Training.WebUI.Presenters
{
	public class LoginPresenter
	{
		private IUserSession _session;
		private IEmployeeRepository _repository;

		public LoginPresenter(IUserSession session, IEmployeeRepository repository)
		{
			_session = session;
			_repository = repository;
		}

		public void Execute(ILoginView view)
		{
			Employee[] employees = _repository.GetAllEmployees();
			view.EmployeesToList = employees;
		}

		public void LogInSelectedUserName(string userName)
		{
			Employee employee = _repository.GetByUserName(userName);
			_session.LogIn(employee);
		}
	}
}